package com.zjcloud.motr.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zjcloud.common.annotation.Log;
import com.zjcloud.common.core.controller.BaseController;
import com.zjcloud.common.core.domain.AjaxResult;
import com.zjcloud.common.enums.BusinessType;
import com.zjcloud.motr.domain.ZjyVenue;
import com.zjcloud.motr.service.IZjyVenueService;
import com.zjcloud.common.utils.poi.ExcelUtil;
import com.zjcloud.common.core.page.TableDataInfo;

/**
 * 场地信息Controller
 * 
 * @author ruoyi
 * @date 2024-08-19
 */
@RestController
@RequestMapping("/motr/venue")
public class ZjyVenueController extends BaseController
{
    @Autowired
    private IZjyVenueService zjyVenueService;

    /**
     * 查询场地信息列表
     */
    @PreAuthorize("@ss.hasPermi('motr:venue:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZjyVenue zjyVenue)
    {
        startPage();
        List<ZjyVenue> list = zjyVenueService.selectZjyVenueList(zjyVenue);
        return getDataTable(list);
    }

    /**
     * 导出场地信息列表
     */
    @PreAuthorize("@ss.hasPermi('motr:venue:export')")
    @Log(title = "场地信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZjyVenue zjyVenue)
    {
        List<ZjyVenue> list = zjyVenueService.selectZjyVenueList(zjyVenue);
        ExcelUtil<ZjyVenue> util = new ExcelUtil<ZjyVenue>(ZjyVenue.class);
        util.exportExcel(response, list, "场地信息数据");
    }

    /**
     * 获取场地信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('motr:venue:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zjyVenueService.selectZjyVenueById(id));
    }

    /**
     * 新增场地信息
     */
    @PreAuthorize("@ss.hasPermi('motr:venue:add')")
    @Log(title = "场地信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZjyVenue zjyVenue)
    {
        return toAjax(zjyVenueService.insertZjyVenue(zjyVenue));
    }

    /**
     * 修改场地信息
     */
    @PreAuthorize("@ss.hasPermi('motr:venue:edit')")
    @Log(title = "场地信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZjyVenue zjyVenue)
    {
        return toAjax(zjyVenueService.updateZjyVenue(zjyVenue));
    }

    /**
     * 删除场地信息
     */
    @PreAuthorize("@ss.hasPermi('motr:venue:remove')")
    @Log(title = "场地信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zjyVenueService.deleteZjyVenueByIds(ids));
    }
}
